package models

import (
	"gitee.com/dashengbuqi/luckdraw/persistent/mysql"
	"log"
)

type LuckdrawUser struct {
	Id         int            `json:"Id"`
	Real_name  string         `json:"real_name"`
	Image      string         `json:"image"`
	Luck_times int            `json:"luck_times"`
	Prize      *LuckdrawAward `json:"prize" xorm:"-"`
}

func GetUsers() []*LuckdrawUser {
	var users []*LuckdrawUser
	err := mysql.MysqlEngine.Find(&users)
	if err != nil {
		log.Println("获取用户数据失败:" + err.Error())
		return nil
	}
	return users
}

func GetUsersByNum(nums []int) []*LuckdrawUser {
	var users []*LuckdrawUser
	err := mysql.MysqlEngine.In("id", nums).Find(&users)
	if err != nil {
		log.Printf("获取用户数据失败,%s", err.Error())
		return nil
	}
	return users
}
